package com.iot.ic.modules.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.iot.ic.common.utils.CustomDateSerializer;
@Entity
@Table(name = "t_trade", catalog = "intraoral_camera")
public class Trade implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -5382326943198061961L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", updatable = false, unique = true, nullable = false)
	private int id;
	@Column(name = "trade_no", nullable = true)
	private String tradeNo;
	@Column(name = "trade_name", nullable = true)
	private String tradeName;
	@JsonSerialize(using = CustomDateSerializer.class)
	@Column(name = "addtime", nullable = true)
	@Temporal(TemporalType.TIMESTAMP)
	private Date addtime;
	
    @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
    @JoinColumn(name = "payee", updatable = false,insertable=true,nullable = false)
    private User payee;  //收款人
    
    @ManyToOne(cascade = CascadeType.MERGE ,fetch = FetchType.EAGER)
    @JoinColumn(name = "payer", updatable = false,insertable=true, nullable = false)
    private User payer; //付款人
    
    @JoinColumn(name = "amount")
    private Double  amount; 
    @JoinColumn(name = "status")
    private String  status; 
    @JoinColumn(name = "note")
    private String  note;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getTradeNo() {
		return tradeNo;
	}
	public void setTradeNo(String tradeNo) {
		this.tradeNo = tradeNo;
	}
	public String getTradeName() {
		return tradeName;
	}
	public void setTradeName(String tradeName) {
		this.tradeName = tradeName;
	}
	public Date getAddtime() {
		return addtime;
	}
	public void setAddtime(Date addtime) {
		this.addtime = addtime;
	}
	
	public User getPayee() {
		return payee;
	}
	public void setPayee(User payee) {
		this.payee = payee;
	}
	public User getPayer() {
		return payer;
	}
	public void setPayer(User payer) {
		this.payer = payer;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public Double getAmount() {
		return amount;
	}
	public void setAmount(Double amount) {
		this.amount = amount;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}
	@Override
	public String toString() {
		return "Trade [id=" + id + ", tradeNo=" + tradeNo + ", tradeName=" + tradeName + ", addtime=" + addtime
				+ ", payeeUser=" + payee + ", payerUser=" + payer + ", amount="
				+ amount + ", status=" + status + ", note=" + note + "]";
	} 
    
}
